package top.blackr.folivora.common.notification;

import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;
import top.blackr.folivora.common.core.enums.ResultEnum;
import top.blackr.folivora.common.core.exception.BizException;

import java.util.Map;

/**
 * @author BlackR
 */
@Component
@AllArgsConstructor
public class NotificationFactory {

    private Map<String, NotificationService> notificationServiceMap;

    public NotificationService getNotification(NotificationEnum notificationType) {
        if (!notificationServiceMap.containsKey(notificationType.getType())) {
            throw new BizException(ResultEnum.NOTIFICATION_TYPE_NOT_SUPPORTED);
        }
        return notificationServiceMap.get(notificationType.getType());
    }


}
